﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Name of digits in english</title>
    <script src="scripts/isValidInput.js"></script>
    <link href="styles/js-console.css" rel="stylesheet" />
</head>
<body>
	<div id="task">
		Write script that asks for a digit and depending on the input shows the name of 
        that digit (in English) using a switch statement.
	</div>
    <label for="inputDigit">Enter digit:</label>
    <input type="text" id="inputDigit" />
    <button onclick="PrintDigitInEnglish()">Show name of digit in english</button>

    <div id="js-console"></div>
    <script src="scripts/js-console.js"></script>

    <script>
        //Write script that asks for a digit and depending on the input shows the name of 
        //that digit (in English) using a switch statement.

        function PrintDigitInEnglish() {
            var digit = parseInt(document.getElementById("inputDigit").value);

            if (isValidInputNumber(digit) && digit >= 0 && digit <= 9) {
                switch (digit) {
                    case 0: jsConsole.writeLine("Zero"); break;
                    case 1: jsConsole.writeLine("One"); break;
                    case 2: jsConsole.writeLine("Two"); break;
                    case 3: jsConsole.writeLine("Three"); break;
                    case 4: jsConsole.writeLine("Four"); break;
                    case 5: jsConsole.writeLine("Five"); break;
                    case 6: jsConsole.writeLine("Six"); break;
                    case 7: jsConsole.writeLine("Seven"); break;
                    case 8: jsConsole.writeLine("Eight"); break;
                    case 9: jsConsole.writeLine("Nine"); break;
                    default: jsConsole.writeLine("Invalid digit"); break;
                }
            }
            else {
                jsConsole.writeLine("Enter valid digit.");
            }
        }
    </script>
</body>
</html>
